Skip to content

Notify when my own Bots finish or fail a turn, with one Notifications switch - #470

Merged
Birfy merged 4 commits into
ThinkFlowLab:mainfrom
Birfy:feat/353-finish-fail-notifications
Oct 20, 2026
Merged

Birfy merged 4 commits into
ThinkFlowLab:mainfrom
Birfy:feat/353-finish-fail-notifications

Conversation

@Birfy

@Birfy Birfy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Fixes #353 (first slice, owner decision 2026-10-20 option a). The rest of #353 (quiet hours, mute, waiting too long, per-trigger switches, merging repeats, friends'/team reminders) is tracked in #469.

What

  • When one of my own Bots finishes or fails a turn while the window is in the background or shows another chat, FlyBot shows one system notification: Coder finished / Coder failed: <reason> (the group name as body for a group turn). Clicking it focuses the window and opens that chat or group. It carries no buttons and never approves, rejects or sends anything.
  • Same rules as the existing approval notification (core/src/client/approval-notices.js): only if the OS already allows notifications (never asks), one per event (tag), nothing from before the window opened.
  • Host: turns.js keeps the last 20 ended turns (endedView, process-local) and they ride live().work.ended; ownedLive keeps only the actor's own Bots. Left out: stopped, switched and retried turns, a friend's Bot, turns a friend started, hidden turns another Bot asked for, face-to-face / inbound-share rooms.
  • Settings → General → Notifications switch (on by default, prefs.notifications), covering approval waiting too.

Test

  • New tests in core/test/approval-notices.test.js (client rules, switch, host filter); authz.test.js (narrowing) and install.test.js (set-prefs).
  • ARCH_DOCS_BASE=origin/main TZ=UTC npm run verify: pass (core 1033, social 291, tree 80, timeline 80, scripts 88, interop 37, live-e2e 16; 0 failures).
  • Not run: live Mac instances, real OS notifications in a desktop build.

Risk tier: T2 (estimate; the controller sets the label)

@Birfy Birfy added agent-pr Pull request opened by an agent enhancement New feature or request area:ui Web/desktop UI and copy area:automation Scheduled tasks and automation labels Oct 20, 2026
@Birfy Birfy self-assigned this Oct 20, 2026
@Birfy

Birfy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Self-review: PASS
Tip SHA: 2d54af3
Ran:

  • ARCH_DOCS_BASE=origin/main TZ=UTC npm run verify (core lint + arch-docs OK, plugin lint, build-client --check, ds-bot-patches check, core 1033 / social 291 / tree 80 / timeline 80 / scripts 88 / interop 37 / live-e2e 16 tests, 0 failures)
  • node .github/scripts/changelog.mjs check (OK)
  • CI at the tip: tests-ok, test, plugins (social/tree/timeline), package all green
  • Diff reviewed against the owner design rules and the Proactive reminders 1/3: event reminders (approval waiting, failed, finished) in app and desktop #353 decision (option a): only my own Bots; a notification only opens the chat (no approve/reject/send, no buttons); never asks for OS permission; one per event via tag; one Notifications switch in Settings → General, on by default, covering approvals; quiet hours / waiting-too-long left out (Proactive reminders 1/3 follow-up: quiet hours, mute, waiting-too-long #469); English UI with zh entries; ownedLive narrows work.ended to the actor's own Bots.
    Not run:
  • live Mac instances (3080/3081) and a desktop build showing real OS notifications
  • smoke bench (dev/smoke.mjs)

@Birfy Birfy added the awaiting-approval PR is green and waits for the maintainer's approval (T2/T3) or a review PASS at its tip label Oct 20, 2026
@github-actions github-actions Bot added the risk:T3 Risk tier T3 (needs a human approval), set by the controller from the diff label Oct 20, 2026
@Birfy
Birfy added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 20, 2026
…notifications

# Conflicts:
#	patches/ds-bot/0008-client-bundle.patch
#	patches/ds-bot/topics.json
@Birfy
Birfy enabled auto-merge October 20, 2026 02:39
@Birfy
Birfy added this pull request to the merge queue Oct 20, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 20, 2026
@Birfy

Birfy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Self-review PASS (after merging main 465357e): merged origin/main into feat/353-finish-fail-notifications (merge commit 91d9eb8, no rebase, no force-push).

  • patches/ds-bot/topics.json: I kept both sides' entries in topic 0001 (main's src/host/schedules.js and test/schedules.test.js, plus this PR's approval-notices.js and its test).
  • Source files merged on their own: i18n.js, authz.js (work.ended filter next to main's changes), channel.js (ended and the notifications pref) and the docs. The diff against the old head 2d54af3 contains only main's Edit and pause scheduled tasks; document missed runs #474 changes.
  • Generated files, following the AGENTS.md recipe: I took main's patches/ds-bot (with the merged topics.json), rebuilt core/client.js, then ran ds-bot-patches.mjs generate. check passes.
  • ARCH_DOCS_BASE=origin/main TZ=UTC npm run verify on Node 24 passed (core 1042/1042, all other suites pass). CI is green.

…notifications

# Conflicts:
#	patches/ds-bot/0008-client-bundle.patch
@Birfy
Birfy enabled auto-merge October 20, 2026 02:44
@Birfy
Birfy added this pull request to the merge queue Oct 20, 2026
@Birfy

Birfy commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator Author

Self-review PASS (after merging main c7898dd): merged origin/main (which now includes #472 Agent inbox) into feat/353-finish-fail-notifications (merge commit e9bf10f, no rebase, no force-push).

  • The only conflict was in the generated patches/ds-bot/0008-client-bundle.patch. I took main's patches/ds-bot and kept the merged topics.json (main's entries plus this PR's approval-notices.js and its test). Then I rebuilt core/client.js and ran ds-bot-patches.mjs generate. check passes.
  • i18n.js (inbox strings and notification strings), client.js and docs/subsystems/core-client.md merged on their own. The diff against the old head 91d9eb8 contains only main's Add Agent inbox step 1: Inbox row with Needs you / In progress / Done #472 changes.
  • ARCH_DOCS_BASE=origin/main TZ=UTC npm run verify on Node 24 passed (core 1057/1057, all other suites pass). CI is green, and the PR is MERGEABLE/CLEAN.

Merged via the queue into ThinkFlowLab:main with commit be60e75 Oct 20, 2026
8 checks passed
@Birfy
Birfy deleted the feat/353-finish-fail-notifications branch October 20, 2026 02:47
Birfy added a commit to Birfy/FlyBot that referenced this pull request Oct 20, 2026
ThinkFlowLab#491)

Part of ThinkFlowLab#471 (first slice, owner decision 2026-10-20 option a). ThinkFlowLab#471
also lists items the owner deferred (board view, tool-call counts,
first-run guide, team views waiting for ThinkFlowLab#51/ThinkFlowLab#149/ThinkFlowLab#55/ThinkFlowLab#57, inbox-side
task actions), so this PR does not close it.

**What**
- **Failed turns in the Agent inbox.** *Needs you* gets a **Failed**
card for a turn of my own Bot that failed, read from `work.ended`, the
same ended-turn entries the finish/fail notifications use (ThinkFlowLab#353, PR
ThinkFlowLab#470); no second event source. A card shows while that failure is the
latest ended turn in its place (a Bot's own chat or one group), younger
than 7 days, and the Bot is not running or waiting for an approval
there. A later finished turn clears it, and that chat is then not also
in *Done*. Title: the chat's last line (*The last turn did not finish*
without the Session list); reason: the failure text. **Open** only.
- **Latest activity row.** Each card may carry one more line, `Latest:
…` (full text on hover): a task's newest note, else what its Bot runs
there now (running turns and tasks only), else the chat's last line.
Left out when it only repeats the title or reason.
- Host (`turns.js`): past the last 20 ended turns, a place's latest turn
is kept while it is a failure younger than 7 days (at most 50), so busy
Bots elsewhere do not push an unresolved failure out of the inbox.
Notifications are unaffected (they already skip entries they told or
that predate the window).
- Out of scope (deferred by the owner): board view, tool-call counts,
team views.

**Test**
- `core/test/inbox.test.js`: failed-turn cards (own Bots only,
latest-in-place, cleared by running/waiting/a later finished turn, 7
days, badge count, Open only) and the latest-activity row (sources, no
repeats, rendering). `core/test/approval-notices.test.js`: the host
keeps a still-latest failure past the last 20 and drops it once a
finished turn follows.
- `ARCH_DOCS_BASE=origin/main TZ=UTC npm run verify`: pass (core 1080,
social 296, tree 80, timeline 83, scripts 93, interop 37, live-e2e 16; 0
failures; plugin lint ok; patches check ok; arch-docs OK).
- Not run: live DSH bench / the owner's Mac instances (no visual check
in a running shell).

Docs: `docs/subsystems/core-client.md` (Agent inbox),
`docs/subsystems/core-host.md` (`endedView`). Changelog:
`changelog.d/471-inbox-failed-turns.added.md`.

Risk tier: T2 (estimate; the controller sets the label)

Co-authored-by: Birfy <15378933+Birfy@users.noreply.github.com>
Birfy added a commit to Birfy/FlyBot that referenced this pull request Oct 20, 2026
… one notification per chat (ThinkFlowLab#492)

Fixes ThinkFlowLab#469 (first slice, owner decision 2026-10-20 option a). Builds on
ThinkFlowLab#353's notifications (ThinkFlowLab#470). Quiet hours, mute and an in-app list stay
for later; friends'/team notifications wait for ThinkFlowLab#51.

**What**
- **Waiting too long:** an approval still waiting 15 min after it
started (or after the window opened, if it started earlier) gets one
more notification: `Coder has waited 15 min for your approval`. A client
timer is set for the next due approval and cleared with the effect; a
decided approval gets none.
- **Per-kind switches:** Settings → General → Notifications keeps the
main switch and adds **Waiting for approval** (covers the reminder),
**Finished** and **Failed** (`prefs.notify`, on unless `false`; disabled
while the main switch is off). `set-prefs` takes `notify: { approval |
finished | failed: boolean }`, keeps only the off ones.
- **One per chat:** every notification of a chat or group shares the tag
`ds-bot-<chat id>`, so a newer one replaces the older, and the body
counts the updates (`3 updates`) since the chat was last on screen or
its notification clicked. Several events of one chat in one pass become
one notification (the newest).
- Unchanged: never asks for permission, nothing from before the window
opened, a click only opens the chat (no buttons, never approves or
sends).

**Test**
- New tests in `core/test/approval-notices.test.js` (reminder timing and
cleanup, reminder for pre-window approvals, per-kind switches, per-chat
collapse and count reset, Settings rows) and `install.test.js`
(`set-prefs notify`).
- `ARCH_DOCS_BASE=origin/main TZ=UTC npm run verify`: pass (core 1082,
social 296, tree 80, timeline 83, scripts 93, interop 37, live-e2e 16; 0
failures). `changelog.mjs check`: ok.
- Not run: live Mac instances, real OS notifications in a desktop build.

Risk tier: T2 (estimate; the controller sets the label)

Co-authored-by: Birfy <15378933+Birfy@users.noreply.github.com>
@Birfy Birfy removed awaiting-approval PR is green and waits for the maintainer's approval (T2/T3) or a review PASS at its tip agent-pr Pull request opened by an agent labels Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:automation Scheduled tasks and automation area:ui Web/desktop UI and copy enhancement New feature or request risk:T3 Risk tier T3 (needs a human approval), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proactive reminders 1/3: event reminders (approval waiting, failed, finished) in app and desktop

1 participant